package bat.ke.qq.com.core;

import bat.ke.qq.com.core.ProxyInvocationHandler;
import bat.ke.qq.com.mapper.UserMapper;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;

import java.lang.reflect.Proxy;

/**
 *
 *
 *
 *
 */
//@Component
public class MyBeanFactoryPostProccesor implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {

        UserMapper userMapper = (UserMapper) Proxy.newProxyInstance(this.getClass().getClassLoader(),new Class[]{UserMapper.class},new ProxyInvocationHandler());
        beanFactory.registerSingleton("userMapper",userMapper);

    }
}
